<{include file="../common/iframe_header.tpl"}>
<form name='myForm1' id='myForm1' method='post' action='/webadmin/netQuestion/DoAnswer'>
    <div style='margin:10px;'>
        <table>
            <tr><td><h3>题目：</h3></td><td><h3><{$subject_info.question_num}> <{$subject_info.title}></h3></td></tr>
            <tr><td>分数：</td><td><input name='answer_score' class="input-text" id="answer_score" type='text' value='<{$answer_info.answer_score}>'>(标准分：<{$subject_info.standard_score}>)</td></tr>
            <{if $subject_info.question_type==2}>
            <tr>
                <td>选项：</td>
                <td>
                    <{foreach $select as $k => $v}>
                    <input type='<{if $subject_info.question_type_sub==3||$subject_info.question_type_sub==5}>radio<{else}>checkbox<{/if}>' name='answer_option[]' <{if $answer_info&&($k|in_array:$answer_info.option)}>checked="checked"<{/if}> value='<{$k}>'/><{$v}>
                    <{/foreach}>
                </td>
            </tr>
            <{/if}>
            <tr><td>描述：</td><td><textarea name='answer_desc' cols='60' rows='5'><{$answer_info.answer_desc}></textarea></td></tr>
            <tr>
                <td>附件：</td>
                <td>
                    <input type='file' id="uploadify">
                    <div id="attach_list">
                        <{if $attach_list}>
                        <{foreach $attach_list as $k => $v}>
                        <a href="<{$v.url}>" target="_blank"><{$v.url}></a><br/>
                        <{/foreach}>
                        <{/if}>
                    </div>
                </td>
            </tr>
            <tr><td colspan='2' style="text-align: center;"><input type='submit' class="button" value='提交'></td></tr>
        </table>
            <input type="hidden" name="standard_score" id="standard_score" value="<{$subject_info.standard_score}>" />
            <input type="hidden" name="answer_id" value="<{$answer_info.answer_id}>" /> 
            <input type='hidden' name='subject_id' value='<{$subject_id}>' />
        <input name='nq_id' type='hidden' value='<{$nq_id}>' />
    </div>
</form>
<script type='text/javascript' src="/js/jquery.uploadify.min.js"></script>
<link href="/css/uploadify.css" rel="stylesheet">
    <script>
        $(document).ready(function() {     
                var options = {         
                    beforeSubmit:  showRequest,  
                    success:       showResponse,
                    dataType:  'json'
                }
                $('#myForm1').ajaxForm(options); 
                
                $('#uploadify').uploadify({
                    'formData'      : {'nq_id' : <{$nq_id}>, 'subject_id' : <{$subject_id}>},
                    'buttonText' : '选择文件',
                    'fileObjName' : 'upfile',   
                    'swf'      : '/js/uploadify.swf',
                    'fileTypeExts' : '*.gif; *.jpg; *.png;*.mp3;*.mp4',
                    'uploader' : '/webadmin/attach/doanswer?attach_type=answer',
                    'onUploadSuccess' : function(file, data, response) {
                        var obj = eval('(' + data + ')');
                        if (obj.state =='SUCCESS'){
                            alert('上传成功');
                            $('#attach_list').append(obj.url+'<br/>');
                        } else {
                            alert(obj.state);
                        }
                    } 
                });   
        });
            function showRequest(formData, jqForm, options) { 
                //判断还的分值是否超过标准分
                var answer_score = $('#answer_score').val();
                var standard_score = $('#standard_score').val();
                if (answer_score > standard_score) {
                    alert('得分不能大于标准分！');return false;
                }
                return true;
            }
            function showResponse(responseText, statusText, xhr, $form)  { 
                alert(responseText.note);
                if (responseText.status==1) {
                    window.parent.location.reload();
                }
            }
    </script>
    <{include file="../common/footer.tpl"}>